/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ces31.ChineseDicesClient.RN;

import ces31.ChineseDicesClient.IU.IU_Jogo_Observer;
import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author Anderson Aiziro
 */
public abstract class RN_Jogo_Subject {
    public void attach(IU_Jogo_Observer obs){
        observers.add(obs);
    }

    public void dettach(IU_Jogo_Observer obs){
        observers.remove(obs);
    }

//    protected void notifyNewMessageToObservers(){
//        Iterator currentobserver = observers.iterator();
//        while(currentobserver.hasNext()){
//            ((IU_Jogo_Observer)currentobserver.next()).atualizarAreaDeTexto();
//        }
//    }
    protected void notifyLastStatementToObservers(){
        Iterator currentobserver = observers.iterator();
        while(currentobserver.hasNext()){
            ((IU_Jogo_Observer)currentobserver.next()).apresentarAfirmacao();
        }
    }
    protected void notifyTimeToPlay() {
        Iterator currentobserver = observers.iterator();
        while(currentobserver.hasNext()){
            ((IU_Jogo_Observer)currentobserver.next()).habilitarJogada();
        }
    }
    protected void notifyEndOfGame(){
        Iterator currentobserver = observers.iterator();
        while(currentobserver.hasNext()){
            ((IU_Jogo_Observer)currentobserver.next()).encerrarJogo();
        }
    }
    protected void notifyNewBoardConfiguration(){
        Iterator currentobserver = observers.iterator();
        while(currentobserver.hasNext()){
            ((IU_Jogo_Observer)currentobserver.next()).atualizarInformacoesJogador();
        }
    }
    private LinkedList observers = new LinkedList();
}
